home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 5644 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.3 KB

  1. Path: rcogate.rco.qc.ca!usenet
  2. From: jds <jds@lino.com>
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: C++ Gurus! Is it correct?
  5. Date: 4 Feb 1996 00:56:49 GMT
  6. Organization: Inter-Acces Communications
  7. Message-ID: <4f108h$3eh@rcogate.rco.qc.ca>
  8. References: <4eqvtg$cg5@israel-info.datasrv.co.il> <4etnju$6gn@rolaids.frco.com> <4f0n8s$a3b@news2.ios.com>
  9. NNTP-Posting-Host: tty24.lino.com
  10.  
  11. vlad@gramercy.ios.com (Vlastimil Adamovsky) wrote:
  12. >
  13. > Jadam@tcmail.frco.com (Jim Adam) wrote:
  14. > >In article <4eqvtg$cg5@israel-info.datasrv.co.il>, dmitry@enigma.co.il 
  15. > >says...
  16. > >>Is next code is correct from point of view of pure C++ ?
  17. > >>class A
  18. > >>{
  19. > >>};
  20. > >>class B
  21. > >>{
  22. > >>};
  23. > >>class C : public A, public B
  24. > >>{
  25. > >>};
  26. > >>A* pA = new C;
  27. > >>B* pB = new C;
  28. > >>delete pA;
  29. > >>delete pB;
  30. > >==========================
  31. > >This is correct.  However, to ensure the destructor for class
  32. > >C gets called correctly, class A and B both need virtual 
  33. > >destructors.
  34. > >E.g., 
  35. > >  class A
  36. > >  {
  37. > >    public:
  38. > >      virtual ~A();
  39. > >  };
  40. > >And likewise for class B.   
  41. > >Jim
  42. > I don't think the virtual destructor is necessary in this specific
  43. > case where you have no added data in subclasses. 
  44.  
  45.  
  46. Do you think we post all our files on this newsgroup????????????????
  47. Jacques
  48. jds@lino.com
  49.  
  50.